-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29277: Invalid index should return null for get_json_object #6144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| json = extract_json_withindex(json, indexList); | ||
| if (indexList.isEmpty()) { | ||
| // Return null if index is invalid. | ||
| return path.contains("[") ? null : json; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we refactor
if (indexList.size() > 0) {
json = extract_json_withindex(json, indexList);
} else if (path.indexOf('[') >= 0) {
return null; // index is invalid
}
deniskuzZ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, pending tests
| #### A masked pattern was here #### | ||
| CBO PLAN: | ||
| HiveProject(id=[$1], id1=[null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id2=[$0]) | ||
| HiveProject(a.id=[$1], b.id=[null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], c.id=[$0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is introduced in #6118
|



What changes were proposed in this pull request?
Return null for invalid index in
get_json_objectudf.Why are the changes needed?
Fix bug.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Add unit test.